//
//  TitleButton.swift
//  weibo
//
//  Created by tomato on 2023/2/8.
//

import UIKit

class TitleButton: UIButton {
    // MARK: - 重写init函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setImage(UIImage(named:"home_arrow_down"), for: UIControl.State.normal)
        setImage(UIImage(named:"home_arrow_up"), for: UIControl.State.selected)
        setTitleColor(UIColor.black, for: UIControl.State.normal)
        sizeToFit()
    }
    //语法规定：重写控件的init,必须重写init?(coder: NSCoder)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLabel!.frame.origin.x = 0
        imageView!.frame.origin.x = titleLabel!.frame.size.width + 5
    }
}
